<template>

	<div class="reveal">

		<div ref="search" class="search flex unified-flex-align">
			<div class="search-icon"><i class="el-icon-search"></i></div>
			<input ref="search-input" class="search-input unified-transition" type="text" name="" id="" value=""
				@focus="searchFocus" @blur="searchBlur" />
			<div ref="search-btn" class="search-btn unified-transition">搜索</div>
		</div>
		<div class="messge-list">
			<el-table :data="list" style="width: 100%" v-loading="pageLoading">
				<!-- 序号 -->
				<el-table-column type="index" label="#" width="60"> </el-table-column>
				<!-- 推送模板名称 -->
				<el-table-column label="Template">
					<template slot-scope="data">
						<el-link type="primary">{{ data.row.template_name }}</el-link>
					</template>
				</el-table-column>
				<!-- 推送成员 -->
				<el-table-column label="Member"> 
				
				
					<template >
						<div class="member-list unified-table-div unifined-text-right">
							
						</div>
					</template>
				
				
				</el-table-column>
				<!-- 推送数量 -->
				<el-table-column prop="number" label="Number" width="100">
					<template slot="header">
						<div class="unified-table-div">
							<span>Number / 条</span>
						</div>
					</template>

					<template slot-scope="data">
						<div class="unified-table-div">
							<span>{{ data.row.member || 0 }}</span>
						</div>
					</template>
				</el-table-column>
				<!-- 推送时间 -->
				<el-table-column label="PUSH Time">
					
					<template slot="header">
						<div class="unified-table-div unifined-text-right">
							<span>PUSH Time</span>
						</div>
					</template>
					
					<template slot-scope="data">
						<div class="unified-table-div unifined-text-right">
							{{ data.row.push_time | turnTime }}
						</div>
					</template>
					
				</el-table-column>
				<!-- 推送状态 -->
				<el-table-column label="State" width="80">
					
					<template slot="header">
						<div class="unified-table-div unifined-text-right">
							<span>State</span>
						</div>
					</template>
					
					<template slot-scope="data">
						<div class="unified-table-div unifined-text-right">
							{{ pushStatus[data.row.status]}}
						</div>
					</template>
					
				</el-table-column>
			</el-table>
		</div>

		<div class="fool-div unified-pagination unified-flex-align unified-flex-center flex">
			<el-pagination :page-sizes="[10]" :page-size="10"
				layout="total, sizes, prev, pager, next, jumper" :total="total">
			</el-pagination>
		</div>
	</div>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	// 引入mixin
	import Mixin from '../../mixin/list.js'
	
	export default {
		mixins:[Mixin],
		computed: {
			...mapState(['emsPushlist']),
		},

		data() {
			return {
				api:this.$api.ems,
				// 推送状态定义
				pushStatus:['完成','部分完成','失败','平台出错','待推'],
				
				// 推送数据
				pushData: [],
			}
		},
		filters: {
			tagName(state) {

				if (state == 0) {

					return "success"

				} else if (state == 1) {

					return "warning"


				} else {

					return "danger"

				}

			}

		},
		methods: {
			// 搜索框获取焦点
			searchFocus() {
				let searchInput = this.$refs[
					'search-input'
				]
				let searchBtm = this.$refs[
					'search-btn'
				]
				searchInput.classList.add('input-focus')
				searchBtm.classList.add('btn-focus')
			},
			// 搜索框失去焦点
			searchBlur() {
				let searchInput = this.$refs[
					'search-input'
				]
				let searchBtm = this.$refs[
					'search-btn'
				]
				searchInput.classList.remove('input-focus')
				searchBtm.classList.remove('btn-focus')
			},

		},
		mounted() {
			
			this.$axios({
				url: this.api,
				method: "GET",
				params: {
					"action": "pushlist",
					"params": {
						page: this.page,
						limit: this.limit
					}
				},
				timeout: 1000,
			}).then(res=>{
				this.list = res.data.data
				this.pages = res.data.pages
				this.page = res.data.page
				this.total = res.data.total
			}).catch(err=>{
				
				if(err.message.search(/timeout/) == 0){
					this.$message.error('服务器响应超时,请重试')
					this.pageLoading = false
				}
				
			})
			
			
		}

	}
</script>

<style scoped="scoped">
	.reveal {
		width: 100%;
		box-sizing: border-box;
	}

	.messge-list {
		width: 96%;
		margin: 0px auto;
		padding-bottom: 0px;
	}

	.cutTag {
		width: 250px;
		height: 35px;
		display: flex;
		margin-left: 20px;
		border-radius: 20px;
		overflow: hidden;
		margin-top: 10px;
		margin-bottom: 00px;
		position: relative;
	}

	.tag-checked {
		width: 50%;
		height: 100%;
		/* background-color: #2269F350; */
		position: absolute;
		opacity: 0.8;
		left: 0;
		top: 0;
		border-radius: 20px;
		z-index: 0;
	}

	.tag-li {
		background-color: transparent;
		text-align: center;
		line-height: 35px;
		width: 50%;
		height: 100%;
		z-index: 10;
		letter-spacing: 1px;
	}


	.search {
		width: 100%;
		height: 65px;
		padding: 5px 20px;
		padding-bottom: 20px;
		box-sizing: border-box;
		position: relative;
	}

	.search-icon {
		width: 30px;
		height: 30px;
		position: absolute;
		text-align: center;
		line-height: 30px;
		font-weight: bold;
		left: 30px;
		top: 30;
	}


	.search-input {
		/* border-top-left-radius: 35px;
		border-bottom-left-radius: 35px; */
		height: 100%;
		flex: 1;
		outline: none;
		border: none;
		text-indent: 45px;
		background-color: #C3C3C344;
	}

	.btn-focus,
	.input-focus {
		/* border: 1px solid #2269F3; */
		box-shadow: 0px 0px 1px 1px #0081FF;
	}

	.btn-focus {
		background-color: #0081FF !important;
	}

	.input-focus {
		background-color: #FFF;
	}

	.search-btn {
		height: 100%;
		width: 120px;
		background-color: #F74F0E;
		/* border-top-right-radius: 35px;
		border-bottom-right-radius: 35px; */
		text-align: center;
		line-height: 40px;
		color: #fff;
		font-size: 12px;
		/* margin-right: 10px; */
		/* font-weight: bold; */
	}
</style>
